//package com.zwd.cases.utils.ftp2;
//
//import com.zwd.cases.demo.model.OssBean;
//import com.zwd.cases.utils.OssUtil;
//import com.zwd.cases.utils.PdfUtil;
//import lombok.extern.slf4j.Slf4j;
//
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
//import java.io.InputStream;
//
///**
// * 通过FTP上传文件-实践2
// *  详细操作步骤可参考： zwd-FTPUtil2-操作步骤明细.md
// */
//@Slf4j
//public class FTPTestMy {
//
//    public static void main(String[] args) throws FileNotFoundException {
//        String ftpPath = "/remote";
//        InputStream inputStream = null;
//        String uploadFileName = "";
//
//        /*
//        // test-001 直接根据字节内容生成test.txt文件上传到ftp
//        String str = "test";
//        inputStream = new ByteArrayInputStream(str.getBytes());
//        uploadFileName = "test.txt";
//        FTPUtils.uploadFile(ftpPath, uploadFileName, inputStream);
//        */
//
//        /*
//        // test-002 本地文件上传到ftp
//        String contextPath = getContextPath();
//        contextPath = contextPath.replace("target/test-classes/", "");
//        String str = contextPath + "src/test/java/com/zwd/cases/demo/file/test/sourceFileName.pdf";
//        System.out.println(str);
//        inputStream = new FileInputStream(new File(str));
//        uploadFileName = "sourceFileName.pdf";
//        FTPUtils.uploadFile(ftpPath, uploadFileName, inputStream);
//        */
//
//        // test-005 从OSS获取文件流直接上传到ftp
//        String endpoint = "oss-cn-hangzhou.aliyuncs.com";
//        String accessKeyId = "LTAI5tNB6ULFGBJBb6GdpbQe";
//        String accessKeySecret = "O57pHsDFuLRixwKqx2bUChl8RjD8BJ";
//        String bucketName = "guli-file-zwd";
//        // 文件存储的，bucketName之后的路径
//        String filePath = "2022/07/21/5b4bdedb-10e6-4cb7-88d6-bc5131f4157fsourceFileName.pdf";
//        uploadFileName = "sourceFileFromOss.pdf";
//
//        OssBean ossBean = new OssBean(endpoint, accessKeyId, accessKeySecret, bucketName, filePath);
//        FTPUtils.uploadFileToFtpFromOss(ftpPath, uploadFileName, ossBean);
//    }
//
//    /**
//     * 获取上下文路径
//     * @return
//     */
//    private static String getContextPath() {
//        return PdfUtil.class.getResource("/").getPath();
//    }
//}
